﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yahoo.Yui.Compressor;

namespace Interfleet.SE.UICompiler.Core.YahooCssCompressor
{
    public class YCCompilerAgent : CompilerAgent
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="args"><see cref="Arguments"/> for the compiler.</param>
        internal YCCompilerAgent(Arguments args)
            : this(
            args, 
            new YCArgumentBuilder(args), 
            new YCResultBuilder(args)
            )
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="args">Arguments for the compiler.</param>
        /// <param name="argumentBuilder"></param>
        /// <param name="resultBuilder"></param>
        public YCCompilerAgent(
            Arguments args, 
            ArgumentBuilder argumentBuilder, 
            ResultBuilder resultBuilder)
            : base(args, argumentBuilder, resultBuilder)
        {

        }

        /// <summary>
        /// Compresses css using the Yahoo Css Compressor.
        /// </summary>
        /// <returns>A <see cref="CompileResult"/></returns>
        public override CompileResult Compile()
        {
            var css = ArgumentBuilder.Build();
            var complationStart = DateTime.Now;
            var result = CssCompressor.Compress(css);
            return ResultBuilder.Build(result, complationStart);
        }
    }
}
